package com.example.capsule_netty.netty;

import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener;
import lombok.extern.slf4j.Slf4j;

/**
 * @Author: zhuzhiming
 * @Date: 2022/4/27 19:17
 */

@Slf4j
public class NettyServer {

    private final NettyManager nettyManager;

    private NettyServer() {
        this.nettyManager = new NettyManager();
    }

    private static class NettyServerBuilder {
        private static final NettyServer INSTANCE = new NettyServer();
    }

    public static NettyServer getInstance() {
        return NettyServerBuilder.INSTANCE;
    }

    public void start() {
        nettyManager.doStart(new ChannelFutureListener() {
            @Override
            public void operationComplete(ChannelFuture channelFuture) throws Exception {
                if (channelFuture.isSuccess()) {
                    log.info("39.106.39.49服务器启动成功~~");
                } else {
                    log.error("服务器启动失败！！" + channelFuture.get());
                }
            }
        });
    }


}
